<!doctype html>



  


<html class="theme-next pisces use-motion">
<head>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PBHRK7');</script>
<!-- End Google Tag Manager -->
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="前端 知识 面试," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.2" />






<meta name="description" content="css 盒子模型1.盒子模型有两种，IE盒子模型、W3C盒子模型；2.盒子模型：内容（content），内边距（padding），边框（border），外边距（margin）3.区别：IE的content部分把border和padding计算进去了  css 选择器 1.id选择器（#id）; 2.类选择器（.class); 3.标签选择器（div）; 4.相邻选择器（h1+p）； 5.子选择器（">
<meta name="keywords" content="前端 知识 面试">
<meta property="og:type" content="article">
<meta property="og:title" content="前端面试《第十篇》 css相关">
<meta property="og:url" content="http://wurh.github.io/2019/03/31/201903310842/index.html">
<meta property="og:site_name" content="华Ing&#39;s blog">
<meta property="og:description" content="css 盒子模型1.盒子模型有两种，IE盒子模型、W3C盒子模型；2.盒子模型：内容（content），内边距（padding），边框（border），外边距（margin）3.区别：IE的content部分把border和padding计算进去了  css 选择器 1.id选择器（#id）; 2.类选择器（.class); 3.标签选择器（div）; 4.相邻选择器（h1+p）； 5.子选择器（">
<meta property="og:locale" content="en">
<meta property="og:updated_time" content="2019-07-12T06:10:38.187Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="前端面试《第十篇》 css相关">
<meta name="twitter:description" content="css 盒子模型1.盒子模型有两种，IE盒子模型、W3C盒子模型；2.盒子模型：内容（content），内边距（padding），边框（border），外边距（margin）3.区别：IE的content部分把border和padding计算进去了  css 选择器 1.id选择器（#id）; 2.类选择器（.class); 3.标签选择器（div）; 4.相邻选择器（h1+p）； 5.子选择器（">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: 'Author'
    }
  };
</script>




  <link rel="canonical" href="http://wurh.github.io/2019/03/31/201903310842/"/>


  <title> 前端面试《第十篇》 css相关 | 华Ing's blog </title>
</head>

<body itemscope itemtype="//schema.org/WebPage" lang="en">
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PBHRK7"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

  










  
  
    
  

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-69412379-1', 'auto');
  ga('send', 'pageview');

</script>

  <script>
  var _hmt = _hmt || [];
  (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b3ddfb8655d8b77429e04c7a4d5bcbc1";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
  })();
  </script>


  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="//schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">华Ing's blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">harder and harder</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
            Tags
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                前端面试《第十篇》 css相关
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2019-03-31T11:30:00+08:00" content="2019-03-31">
              2019-03-31
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/前端面试/" itemprop="url" rel="index">
                    <span itemprop="name">前端面试</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2019/03/31/201903310842/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2019/03/31/201903310842/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="css-盒子模型"><a href="#css-盒子模型" class="headerlink" title="css 盒子模型"></a>css 盒子模型</h3><p>1.盒子模型有两种，IE盒子模型、W3C盒子模型；<br>2.盒子模型：内容（content），内边距（padding），边框（border），外边距（margin）<br>3.区别：IE的content部分把border和padding计算进去了</p>
<hr>
<h3 id="css-选择器"><a href="#css-选择器" class="headerlink" title="css 选择器"></a>css 选择器</h3><ul>
<li>1.id选择器（#id）;</li>
<li>2.类选择器（.class);</li>
<li>3.标签选择器（div）;</li>
<li>4.相邻选择器（h1+p）；</li>
<li>5.子选择器（ul&gt;li）；</li>
<li>6.后代选择器（li a）；</li>
<li>7.通配符（*）；</li>
<li>8.属性选择器（a[rel = ‘xyz’];</li>
<li>9.伪类选择器（a:hover,li:nth-child);</li>
</ul>
<blockquote>
<p>可继承样式：font-size font-family color ul li dl dd dt;</p>
</blockquote>
<blockquote>
<p>不可继承样式：border padding margin width height；</p>
</blockquote>
<hr>
<h3 id="CSS优先级算法如何计算？"><a href="#CSS优先级算法如何计算？" class="headerlink" title="CSS优先级算法如何计算？"></a>CSS优先级算法如何计算？</h3><p>优先级就近原则，同权重样式定义最近者为准<br>载入样式以最后载入的定位为准</p>
<p>优先级：<br>!important &gt; id &gt; class &gt; tag &gt; *(通配符)</p>
<hr>
<h3 id="display有哪些值？说明他们的作用"><a href="#display有哪些值？说明他们的作用" class="headerlink" title="display有哪些值？说明他们的作用"></a>display有哪些值？说明他们的作用</h3><ul>
<li>1.block:设定元素变为块级元素，占据一整行，可设置宽高；</li>
<li>2.inline-block：设定元素为行内块元素，可设置宽高，一行能显示多个；</li>
<li>3.inline：行内元素，不可设置宽高，一行可显示多个；</li>
<li>4.none：设置元素不可见；</li>
<li>5.flex：开启弹性布局；</li>
<li>6.table：作为块级表格显示；</li>
<li>7.list-item：像块级元素一样显示，并添加样式列表标记；</li>
<li>8.inherit：继承父元素的display属性；</li>
</ul>
<hr>
<h3 id="position的值relative和absolute定位原点是？"><a href="#position的值relative和absolute定位原点是？" class="headerlink" title="position的值relative和absolute定位原点是？"></a>position的值relative和absolute定位原点是？</h3><ul>
<li>elative：相对定位，相对于正常位置进行定位</li>
<li>absolute：绝对定位，相对于父元素中最近一个position不为 static（静态，无定位）定位；</li>
<li>fixed：相对于浏览器窗口定位；</li>
<li>static：默认，无定位；</li>
<li>inherit：继承父元素的定位；</li>
</ul>
<hr>
<h3 id="CSS3有哪些新特性？"><a href="#CSS3有哪些新特性？" class="headerlink" title="CSS3有哪些新特性？"></a>CSS3有哪些新特性？</h3><ul>
<li>1.圆角            –》border-radius</li>
<li>2.阴影和反射         –》shadow、reflect</li>
<li>3.文字特效          –》text-shadow</li>
<li>4.文字渲染          –》text-decoration</li>
<li>5.线性渐变          –》gradient</li>
<li>6.旋转            –》transform</li>
</ul>
<blockquote>
<p>缩放、定位、倾斜、动画、多背景</p>
</blockquote>
<blockquote>
<p>transform：scale（1.1,1.2）；</p>
</blockquote>
<blockquote>
<p>transform：translate（x，y）；</p>
</blockquote>
<blockquote>
<p>transform：skew（9deg，0deg）</p>
</blockquote>
<hr>
<h3 id="用纯CSS创建一个三角形"><a href="#用纯CSS创建一个三角形" class="headerlink" title="用纯CSS创建一个三角形"></a>用纯CSS创建一个三角形</h3><p>原理是将上、左、右的颜色设为透明transparent</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-id">#demo</span>&#123;</span><br><span class="line">    <span class="attribute">width</span>:<span class="number">0</span>;</span><br><span class="line">    <span class="attribute">height</span>:<span class="number">0</span>;</span><br><span class="line">    <span class="attribute">border-width</span>:<span class="number">20px</span>;</span><br><span class="line">    <span class="attribute">border-style</span>:solid;</span><br><span class="line">    <span class="attribute">border-color</span>:transparent transparent red transparent;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>
<hr>
<h3 id="常见的浏览器兼容性问题及其解决方法，常用的hack方法。"><a href="#常见的浏览器兼容性问题及其解决方法，常用的hack方法。" class="headerlink" title="常见的浏览器兼容性问题及其解决方法，常用的hack方法。"></a>常见的浏览器兼容性问题及其解决方法，常用的hack方法。</h3><ul>
<li>1.png24位图片在IE6浏览器上出现背景，解决方法：将图片做成png8；</li>
<li>2.浏览器默认的样式不同。解决方法：设置初始样式清除。或者使用normalize.css进行样式统一。</li>
<li>3.IE6出现双倍外边距的问题，在IE6里，块元素设置浮动后，再设置margin会出现双外边距的问题；解决方法：使用css-hack，在原本的margin：10px；后面加一个 _margin：10px；</li>
<li>4.Chrome中文界面下回默认将小于12px的文本强制按照12px显示，解决方法：加入CSS属性 -webkit-text-size-adjust:none;</li>
<li>注意点.超链接访问过后hover样式不生效，解决方法：按照L-V-H-A顺序书写a:link –&gt;a:visited –&gt;a:hover –&gt;a:active</li>
</ul>
<hr>
<h3 id="li标签之间的空白间隙原因及其解决方法"><a href="#li标签之间的空白间隙原因及其解决方法" class="headerlink" title="li标签之间的空白间隙原因及其解决方法"></a>li标签之间的空白间隙原因及其解决方法</h3><p>行的排列会受到中间空白（回车/空格）的影响，因为空格也是一种字符，也会被应用样式，会占空间<br>解决方法：把字符大小设为0；<br>问题扩展：<br>在块级元素中包含img标签，会出现空隙的问题；<br>因为图片文字等inline元素默认的和父元素对其的方式是 baseline，而baseline与父级的底部有间隙。(w3c中img标签默认是一个inline标签)<br>解决方法：将对齐方式设为除了baseline以外的任何一种:<br><code>vertical-align:top/bottom/text-top/text-bottom</code><br>其实这个空隙是ie针对盒子模型设定的inline-height，和font-size；<br>所以也可以给img设置display:block;font-size:0;但是对于结构来说，有点本末倒置的意味。</p>
<h3 id="在CSS中，visibility有个collapse属性，是干嘛的？"><a href="#在CSS中，visibility有个collapse属性，是干嘛的？" class="headerlink" title="在CSS中，visibility有个collapse属性，是干嘛的？"></a>在CSS中，visibility有个collapse属性，是干嘛的？</h3><p>collapse是崩塌，失效的意思。<br>对于普通的元素visibility:collapse和display:none 表现相同，使元素隐藏并且不占据空间。<br>但是对于table来说，table会被隐藏，但是依然占据空间（ie不支持）</p>
<h3 id="为什么要清除浮动？清除浮动的方式？"><a href="#为什么要清除浮动？清除浮动的方式？" class="headerlink" title="为什么要清除浮动？清除浮动的方式？"></a>为什么要清除浮动？清除浮动的方式？</h3><p>清除浮动是为了清除使用浮动的元素造成的影响；浮动的元素，高度会塌陷，对布局不利。<br>解决方法：</p>
<ul>
<li>1.给父级div设置高度height</li>
<li>2.使父级div也一起浮动</li>
<li>3.给父级元素设置 overf:hidden;</li>
<li>4.使用clearfix类名</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="selector-class">.clearfix</span><span class="selector-pseudo">:before</span>,<span class="selector-class">.clearfix</span><span class="selector-pseudo">:after</span>&#123;</span><br><span class="line">       <span class="attribute">content</span>:<span class="string">""</span>;</span><br><span class="line">       <span class="attribute">display</span>:block;</span><br><span class="line">       <span class="attribute">height</span>:<span class="number">0</span>;</span><br><span class="line">       <span class="attribute">line-height</span>:<span class="number">0</span>;</span><br><span class="line">       <span class="attribute">visibility</span>:hidden;</span><br><span class="line">       <span class="attribute">clear</span>:both</span><br><span class="line">   &#125;</span><br><span class="line">   <span class="selector-class">.clearfix</span>&#123;</span><br><span class="line">       *zoom:1;</span><br><span class="line">   &#125;</span><br></pre></td></tr></table></figure>
<hr>
<h3 id="元素竖向的百分比设定是相对于容器的高度吗"><a href="#元素竖向的百分比设定是相对于容器的高度吗" class="headerlink" title="元素竖向的百分比设定是相对于容器的高度吗?"></a>元素竖向的百分比设定是相对于容器的高度吗?</h3><p>对于height属性来说，设置百分比就是设置相对于容器的百分比<br>对于margin、padding来说，设置竖向百分比却是以容器的宽度来计算</p>
<hr>
<h3 id="什么是响应式设计？响应式设计的基本原理是什么？"><a href="#什么是响应式设计？响应式设计的基本原理是什么？" class="headerlink" title="什么是响应式设计？响应式设计的基本原理是什么？"></a>什么是响应式设计？响应式设计的基本原理是什么？</h3><p>响应式设计（Responsive Web design）：集中创建页面的图片排版大小，可以智能的根据用户使用的设备环境（系统平台、屏幕尺寸、屏幕定向等）进行对应的布局。<br>基本原理：使用@media媒体查询，然后使用不同的CSS规则来实现屏幕的最佳布局。</p>
<hr>
<h3 id="position-fixed-在手机端下无效怎么处理？"><a href="#position-fixed-在手机端下无效怎么处理？" class="headerlink" title="position:fixed;在手机端下无效怎么处理？"></a>position:fixed;在手机端下无效怎么处理？</h3><p>fixed的元素是相对于整个页面固定位置的，你在屏幕上滑动是在滑动整个viewport。<br>原来的网页还在，fixed也没有变过位置，所以说并不是手机端不支持fixed，只是fixed元素不是相对于手机屏幕固定的<br>我们可以设置</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"</span>/&gt;</span></span><br></pre></td></tr></table></figure>
<hr>
<h3 id="怎么实现div的居中？"><a href="#怎么实现div的居中？" class="headerlink" title="怎么实现div的居中？"></a>怎么实现div的居中？</h3><h4 id="水平居中"><a href="#水平居中" class="headerlink" title="水平居中"></a>水平居中</h4><p>1.给div设置宽度，并使用margin：0 auto;</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">   <span class="attribute">width</span>:<span class="number">100px</span>;</span><br><span class="line">   <span class="attribute">height</span>:<span class="number">100px</span>;</span><br><span class="line">   <span class="attribute">margin</span>:<span class="number">0</span> auto;</span><br><span class="line">   <span class="attribute">background</span>:hotpink;</span><br><span class="line">   &#125;</span><br></pre></td></tr></table></figure>
<p>2.使用绝对定位</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">       <span class="attribute">position</span>:absolute；</span><br><span class="line">       width:<span class="number">100px</span>;</span><br><span class="line">       <span class="attribute">height</span>:<span class="number">100px</span>;</span><br><span class="line">       <span class="attribute">left</span>:<span class="number">50%</span>;</span><br><span class="line">       <span class="attribute">margin-left</span>:-<span class="number">50px</span>;</span><br><span class="line">       <span class="attribute">background-color</span>:skyblue;</span><br><span class="line">   &#125;</span><br></pre></td></tr></table></figure>
<h4 id="水平垂直居中"><a href="#水平垂直居中" class="headerlink" title="水平垂直居中"></a>水平垂直居中</h4><p>使用绝对定位</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">    <span class="attribute">position</span>:absolute；</span><br><span class="line">    width:<span class="number">100px</span>;</span><br><span class="line">    <span class="attribute">height</span>:<span class="number">100px</span>;</span><br><span class="line">    <span class="attribute">left</span>:<span class="number">50%</span>;</span><br><span class="line">    <span class="attribute">top</span>:<span class="number">50%</span>;</span><br><span class="line">    <span class="attribute">margin-left</span>:-<span class="number">50px</span>;</span><br><span class="line">    <span class="attribute">margin-top</span>:-<span class="number">50px</span>;</span><br><span class="line">    <span class="attribute">background-color</span>:skyblue;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>使用transform属性</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="selector-tag">div</span>&#123;</span><br><span class="line">    <span class="attribute">position</span>:absolute；</span><br><span class="line">    width:<span class="number">100px</span>;</span><br><span class="line">    <span class="attribute">height</span>:<span class="number">100px</span>;</span><br><span class="line">    <span class="attribute">left</span>:<span class="number">50%</span>;</span><br><span class="line">    <span class="attribute">top</span>:<span class="number">50%</span>;</span><br><span class="line">    <span class="attribute">transform</span>:<span class="built_in">translate</span>(-50%,-50%)</span><br><span class="line">    background-color:skyblue;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>使用弹性布局</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.container</span>&#123;</span><br><span class="line">        <span class="attribute">display</span>:flex;</span><br><span class="line">        <span class="attribute">align-items</span>:center;</span><br><span class="line">        <span class="attribute">justify-content</span>:center;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="selector-class">.container</span> <span class="selector-tag">div</span>&#123;</span><br><span class="line">        <span class="attribute">width</span>:<span class="number">100px</span>;</span><br><span class="line">        <span class="attribute">height</span>:<span class="number">100px</span>;</span><br><span class="line">        <span class="attribute">background-color</span>:hotpink;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="https://wurh.github.io/images/others/weixinshou.png" alt="华Ing WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="https://wurh.github.io/images/others/alifu.png" alt="华Ing Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/前端-知识-面试/" rel="tag">#前端 知识 面试</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/03/31/201903310753/" rel="next" title="前端面试《第九篇》浏览器帧原理">
                <i class="fa fa-chevron-left"></i> 前端面试《第九篇》浏览器帧原理
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/03/31/201903311132/" rel="prev" title="前端面试《第十一篇》 Node.js相关">
                前端面试《第十一篇》 Node.js相关 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        
<script>
  with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='//bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
</script>

      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2019/03/31/201903310842/"
           data-title="前端面试《第十篇》 css相关" data-url="http://wurh.github.io/2019/03/31/201903310842/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            Overview
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="//schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="https://wurh.github.io/images/avatar/logo.jpg?123456"
               alt="华Ing" />
          <p class="site-author-name" itemprop="name">华Ing</p>
          <p class="site-description motion-element" itemprop="description">harder and harder</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">56</span>
              <span class="site-state-item-name">posts</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">11</span>
                <span class="site-state-item-name">categories</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">15</span>
                <span class="site-state-item-name">tags</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/wurh" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/1674582564/profile?topnav=1&wvr=6" target="_blank" title="微博">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  微博
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.zhihu.com/people/wu-rong-hua-56" target="_blank" title="知乎">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  知乎
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Links
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://fsiaonma.github.io/" title="sam博客" target="_blank">sam博客</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://shenjoel.github.io/" title="joel博客" target="_blank">joel博客</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://firewood1122.github.io" title="firewood博客" target="_blank">firewood博客</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://reqianduan.com" title="热前端" target="_blank">热前端</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://opentutorial.info/" title="黄超博客" target="_blank">黄超博客</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#css-盒子模型"><span class="nav-number">1.</span> <span class="nav-text">css 盒子模型</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#css-选择器"><span class="nav-number">2.</span> <span class="nav-text">css 选择器</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#CSS优先级算法如何计算？"><span class="nav-number">3.</span> <span class="nav-text">CSS优先级算法如何计算？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#display有哪些值？说明他们的作用"><span class="nav-number">4.</span> <span class="nav-text">display有哪些值？说明他们的作用</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#position的值relative和absolute定位原点是？"><span class="nav-number">5.</span> <span class="nav-text">position的值relative和absolute定位原点是？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#CSS3有哪些新特性？"><span class="nav-number">6.</span> <span class="nav-text">CSS3有哪些新特性？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#用纯CSS创建一个三角形"><span class="nav-number">7.</span> <span class="nav-text">用纯CSS创建一个三角形</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#常见的浏览器兼容性问题及其解决方法，常用的hack方法。"><span class="nav-number">8.</span> <span class="nav-text">常见的浏览器兼容性问题及其解决方法，常用的hack方法。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#li标签之间的空白间隙原因及其解决方法"><span class="nav-number">9.</span> <span class="nav-text">li标签之间的空白间隙原因及其解决方法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#在CSS中，visibility有个collapse属性，是干嘛的？"><span class="nav-number">10.</span> <span class="nav-text">在CSS中，visibility有个collapse属性，是干嘛的？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#为什么要清除浮动？清除浮动的方式？"><span class="nav-number">11.</span> <span class="nav-text">为什么要清除浮动？清除浮动的方式？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#元素竖向的百分比设定是相对于容器的高度吗"><span class="nav-number">12.</span> <span class="nav-text">元素竖向的百分比设定是相对于容器的高度吗?</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#什么是响应式设计？响应式设计的基本原理是什么？"><span class="nav-number">13.</span> <span class="nav-text">什么是响应式设计？响应式设计的基本原理是什么？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#position-fixed-在手机端下无效怎么处理？"><span class="nav-number">14.</span> <span class="nav-text">position:fixed;在手机端下无效怎么处理？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#怎么实现div的居中？"><span class="nav-number">15.</span> <span class="nav-text">怎么实现div的居中？</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#水平居中"><span class="nav-number">15.1.</span> <span class="nav-text">水平居中</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#水平垂直居中"><span class="nav-number">15.2.</span> <span class="nav-text">水平垂直居中</span></a></li></ol></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2013 - 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">华Ing</span>
</div>

<div class="powered-by">
  Powered by <a class="theme-link" href="https://hexo.io">Hexo</a>
</div>

<div class="theme-info">
  Theme -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.2"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.0.2"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.0.2"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.2"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"wurh"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  






  
  

  

  

  

  


</body>
</html>
